#include "stdafx.h"
#include "CppUnitTest.h"

#include <SnakeLib/Board.h>
#include <SnakeLib/BoardCodec.h>
#include <SnakeLib/ISolver.h>
#include <SnakeLib/Problem.h>

#include "SnakeAssert.h"

template<>
std::wstring Microsoft::VisualStudio::CppUnitTestFramework::ToString<snake::EDirection>(const snake::EDirection &direction)
  {
  switch (direction)
    {
    case snake::LEFT:
      return L"LEFT";
    case snake::RIGHT:
      return L"RIGHT";
    case snake::UP:
      return L"UP";
    case snake::DOWN:
      return L"DOWN";
    default:
      return L"?";
    }
  }

void snake::Assert::Solve(const std::string &board_str, snake::ISolver &solver, snake::EDirection direction)
{
  BoardCodec board_codec;
  Problem problem(board_codec.FromString(board_str));

  snake::EDirection solution = solver.Solve(problem);

  Microsoft::VisualStudio::CppUnitTestFramework::Assert::AreEqual(direction, solution);
}